<?php

namespace app\api\controller;

use app\Request;
use app\api\model\Scores;

class ScoresController
{

    public function addScoresData(Request $request)
    {
        $param = Scores::param($request);
        $soureData = [
            'user_id' => $param['user_id'],
            'chinese' => $param['chinese'],
            'english' => $param['english'],
            'mathematics' => $param['mathematics'],
            'score' => $param['chinese']+$param['english']+$param['mathematics'],
        ];
        $res = Scores::saveScoreData($soureData);
        if(!$res){
            return json(['data'=>[],'msg'=>'添加失败','code'=>400]);
        }
        return json(['data'=>[],'msg'=>'添加成功','code'=>200]);
    }
}